package second.codeTop.package1;

/**
 * @ClassName LC122
 * @description: 买卖股票的最佳时机||
 * @author: 荣燊
 * @create: 2022-03-07 15:00
 **/
public class LC122 {
    public static void main(String[] args) {

    }

    // 贪心算法
    public static int maxProfit(int[] prices) {
        int ans = 0;
        for (int i=1; i<prices.length; i++) {
            ans += Math.max(0, prices[i]-prices[i-1]);
        }
        return ans;
    }
}
